package com.woniu.park.dao;

import com.woniu.park.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author cxb
 * @since 2020-09-05
 */
public interface UserMapper extends BaseMapper<User> {

    @Select("select * from sp_user where user_name=#{username}")
    User findByUsername(String username);
    @Select("select role_value from sp_user_role w1 LEFT JOIN sp_role w2 on w1.role_id=w2.role_id where user_id=#{userId}")
    Set<String> findRoleById(int userId);
    @Select("select perm_value from sp_role_perm w1 LEFT JOIN sp_perm w2 on w1.perm_id=w2.perm_id LEFT JOIN sp_user_role w3 on w1.role_id=w3.role_id where w3.user_id=#{userId}")
    Set<String> findPermById(int userId);
    //根据用户身份证获取id
    @Select("select user_id from sp_user where user_idNumber=#{userIdnumber}")
    public int acquireId(String userIdnumber);
    //根据邀请码查询id
    @Select("select user_id from sp_user where user_regist_number=#{userRegistNumber}")
    User selectInviter(String userRegistNumber);
    //根据电话查用户
    @Select("select * from sp_user where user_tel=#{tel}")
    User selectTel(String tel);
}
